<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display-el" %>
<%@ taglib uri="ford-arg/tags" prefix="ft" %>

<script language="JavaScript" src="./scripts/CalendarPopup.js"></script>  
<script language="JavaScript" src="./scripts/popups.js"></script>
<script language="javascript" src="./scripts/ajaxSearch.js"></script>

<script language="javascript">

	var cal = new CalendarPopup(); 
	cal.showNavigationDropdowns();
	cal.setMonthNames('<bean:message key="label.month.january"/>',
						'<bean:message key="label.month.february"/>',
						'<bean:message key="label.month.march"/>',
						'<bean:message key="label.month.april"/>',
						'<bean:message key="label.month.may"/>',
						'<bean:message key="label.month.june"/>',
						'<bean:message key="label.month.july"/>',
						'<bean:message key="label.month.august"/>',
						'<bean:message key="label.month.september"/>',
						'<bean:message key="label.month.october"/>',
						'<bean:message key="label.month.november"/>',
						'<bean:message key="label.month.december"/>');
	cal.setDayHeaders('<bean:message key="label.day.sunday.capital"/>',
						'<bean:message key="label.day.monday.capital"/>',
						'<bean:message key="label.day.tuesday.capital"/>',
						'<bean:message key="label.day.wednesday.capital"/>',
						'<bean:message key="label.day.thursday.capital"/>',
						'<bean:message key="label.day.friday.capital"/>',
						'<bean:message key="label.day.saturday.capital"/>');
	cal.setTodayText('<bean:message key="label.today"/>');

	function findRequestItems() {
		document.RequestPopupForm.action = "RequestPopupActionFind.do";
		document.RequestPopupForm.section.value = "find";
		document.RequestPopupForm.submit();	
	}
	
	function viewObs(rowNum){
		window.open("RequestsActionViewObs.do?selectedIndex="+rowNum, "", "width=570px, height=210px, resizable, status=1,scrollbars=1");
	}
	
	function clearFindFilds(){
		document.getElementById('partPrefix').value="";    
		document.getElementById('partBase').value="";
		document.getElementById('partSuffix').value="";
		document.getElementById('dateFrom').value="";
		document.getElementById('dateTo').value="";  
		document.getElementById('userCode').value="";
		document.getElementById('commodity').selectedIndex=0;
		document.getElementById('status').selectedIndex=0;
		document.getElementById('partClass').selectedIndex=0;
		document.getElementById('dateFilter').selectedIndex=0;
		document.getElementById('userField').selectedIndex=0;
		document.RequestPopupForm.section.value = "cleanFind";
	}
	
	function selectRequestItem(requestCode,itemCode){
		fulleCode = document.getElementById('fulleCode').value;
		window.opener.document.FullEconomicsExcercisesForm.action = "FullEconomicsExcercisesActionSetRequest.do?fulleCode="+fulleCode+"&requestCode="+requestCode+"&itemCode="+itemCode;
		window.opener.document.FullEconomicsExcercisesForm.submit();
		window.close();
		
	}
	

</script>
	
<table>
	<tr>
		<td colspan="2"><h2><bean:message key="request.label.title"/></h2></td>
	</tr>
</table>
<br/>
<html:form action="/RequestPopupActionInit">
<html:hidden property="section" />
<html:hidden property="fulleCode"/>
<html:hidden property="supplierCode"/>
<html:hidden property="supplierClass"/>

	<%-- Mantiene el numero de pagina despues del submit --%>
	<ft:saveActivePageNumber/>

	<bean:define id="requestTitle">
		<bean:message key="request.label" />
	</bean:define>
	<bean:define id="itemTitle">
		<bean:message key="requestDetail.label.tableHeader.item" />
	</bean:define>
	<bean:define id="supplierTitle">
		<bean:message key="supplier.label.supplier" />
	</bean:define>
	<bean:define id="statusTitle">
		<bean:message key="request.label.status" />
	</bean:define>
	<bean:define id="typeTitle">
		<bean:message key="requestDetail.label.tableHeader.type" />
	</bean:define>
	<bean:define id="descriptionTitle">
		<bean:message key="requestDetail.label.tableHeader.description" />
	</bean:define>
	<bean:define id="percentIncreaseTitle">
		<bean:message key="requestDetail.label.tableHeader.percentIncrease" />
	</bean:define>
	<bean:define id="priceTitle">
		<bean:message key="requestDetail.label.tableHeader.price" />
	</bean:define>
	<bean:define id="effDateTitle">
		<bean:message key="requestDetail.label.tableHeader.effDate" />
	</bean:define>
	<bean:define id="vehicleLineTitle">
		<bean:message key="requestDetail.label.tableHeader.vehicleLine" />
	</bean:define>
	<bean:define id="creationTitle">
		<bean:message key="user.label.creation" />
	</bean:define>
	<bean:define id="closureTitle">
		<bean:message key="request.label.tableHeader.closure" />
	</bean:define>
	<bean:define id="obsTitle">
		<bean:message key="request.label.tableHeader.obs" />
	</bean:define>
	<bean:define id="actionsTitle">
		<bean:message key="request.label.tableHeader.actions" />
	</bean:define>
	<bean:define id="EconLevelTitle">
		<bean:message key="requestDetail.label.tableHeader.econLevel" />
	</bean:define>
	<table style="width: 800px;" class="no_border">
		<tr>
			<td class="text_blue_bold align_left" style="width: 9%;">
				<bean:message key="part.label.filter" />
			</td>
			<td style="width: 44%;"></td>
			<td style="width: 7%;"></td>
			<td style="width: 40%;"></td>
			
		</tr>
		<tr>
			<td class="text_blue_bold align_left">
				<bean:message key="commodity.label" />
			</td>
			<td class="align_left">
				<html:select property="commodityCode" styleId="commodity">
					<html:option value="-1"><bean:message key="label.allOption" /></html:option>
					<html:options collection="commColl"
								  property="eesp02CommodityNumberK"
								  labelProperty="eesp02CommodityNameN" />
				</html:select>
			</td>
			<td class="text_blue_bold align_left">
				<bean:message key="request.label.date"/>
			</td>
			<td class="text_blue_bold align_left" colspan="2">
				<html:select property="dateFilter" styleId="dateFilter">
					<html:option value="-1"><bean:message key="label.allOption" /></html:option>
					<html:options collection="dateFields"
								  property="value"
								  labelProperty="label" />
				</html:select>
				<bean:message key="request.label.from"/>
				<html:text styleId="dateFrom" property="dateFrom" maxlength="10" size="9"/><A name="dateFromAnchor"> </A><html:button property="calendar" onclick="cal.select(document.RequestPopupForm.dateFrom,'dateFromAnchor','dd/MM/yyyy'); return false;" styleClass="button_small">...</html:button>
				<bean:message key="request.label.to"/>&nbsp;
				<html:text styleId="dateTo" property="dateTo" maxlength="10" size="9"/><A name="dateToAnchor"> </A><html:button property="calendar" onclick="cal.select(document.RequestPopupForm.dateTo,'dateToAnchor','dd/MM/yyyy'); return false;" styleClass="button_small">...</html:button>
			</td>
		</tr>
		<tr>
			<td class="text_blue_bold align_left">
				<bean:message key="part.label" />
			</td>
			<td class="text_blue_bold align_left" colspan="2"> 
				<html:select property="partClass" styleId="partClass">
					<html:option value="-1"><bean:message key="label.allOption" /></html:option>
					<html:options collection="partClassColl"
								  property="value"
								  labelProperty="label" />
				</html:select> 
				<html:text styleId="partPrefix" property="prefix" maxlength="10" size="9"/>&nbsp;
				<html:text styleId="partBase" property="base" maxlength="10" size="9"/>&nbsp;
				<html:text styleId="partSuffix" property="suffix" maxlength="10" size="9"/>
				<html:button property="parF" onclick="searchNamePart('lookupedPart','partClass','partPrefix','partBase','partSuffix');" styleClass="button_small" style="width:20px;">...</html:button>
				<html:button property="findParts" onclick="findPartPopup('supplierClass', 'supplierCode', 'partClass', 'partPrefix', 'partBase', 'partSuffix');" styleClass="button_small" style="width:20px;">?</html:button>				
				
			</td>
			<td class="text_blue_bold align_left" colspan="2">
				<div style="display:inline;" id="lookupedPart" />
			</td>
			
		</tr>
		<tr>
			<td class="text_blue_bold align_left">
				<bean:message key="label.user" />:
			</td>
			<td class="align_left" colspan="3"> 
				<html:select property="userField" styleId="userField">
					<html:option value="-1"><bean:message key="label.allOption" /></html:option>
					<html:options collection="userFields"
								  property="value"
								  labelProperty="label" />
				</html:select>
				<html:text property="userCode" styleId="userCode" size="10"></html:text>
			</td>
		</tr>
		<tr>
			<td class="text_blue_bold align_left">
				<bean:message key="request.label.status"/>
			</td>
			<td class="align_left"> 
				<html:select property="status" styleId="status">
					<html:option value="-1"><bean:message key="label.allOption" /></html:option>
					<html:options collection="statusColl"
								  property="value"
								  labelProperty="label" />
				</html:select>
			</td>
			<td class="text_blue_bold align_right" colspan="3">
				<html:button property="find" onclick="findRequestItems();" styleClass="button"><bean:message key="label.find" /></html:button>&nbsp;			
				<input type="button" value="<bean:message key="label.clean"/>" class="button" onclick="clearFindFilds();" />
			</td>
		</tr>
	</table>
	<br/>
		
	<table class="no_border" style="width: 800px;">
		<tr>
			<td>
				<display-el:table 	class="table1" style="width: 800px;" cellpadding="5" uid="requestItem"
									 pagesize="15" name="sessionScope.RequestPopupForm.requestItemColl" 
									excludedParams="*" requestURI="RequestsActionPaginate.do" >
					<display-el:column title="${requestTitle}" property="teesr01Request.eesr01RequestNumberK" style="width: 10%;" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right"/>
					<display-el:column title="${itemTitle}" property="eesr02ReqitmNumberK" style="width: 10%;" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right"/>
					<display-el:column title="${typeTitle}" style="width: 6%;" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
						<logic:equal name="requestItem" property="eesr02ReqitmTypeCodeC" value="A">*</logic:equal>
						<logic:equal name="requestItem" property="eesr02ReqitmTypeCodeC" value="C">Comm</logic:equal>
						<logic:equal name="requestItem" property="eesr02ReqitmTypeCodeC" value="P">Part</logic:equal>
					</display-el:column>
					<display-el:column title="${descriptionTitle}" style="width: 24%;" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
						<logic:equal name="requestItem" property="eesr02ReqitmTypeCodeC" value="A"><bean:message key="requestDetail.label.allParts"/></logic:equal>
						<logic:equal name="requestItem" property="eesr02ReqitmTypeCodeC" value="C">
							<bean:write name="requestItem" property="teesp02Commodity.eesp02CommodityNumberK"/>:
							<bean:write name="requestItem" property="teesp02Commodity.eesp02CommodityNameN"/>
						</logic:equal>
						<logic:equal name="requestItem" property="eesr02ReqitmTypeCodeC" value="P">
							<bean:write name="requestItem" property="teesp04Supply.teesp01Part.eesp01PartClassCodeC"/>
							<bean:write name="requestItem" property="teesp04Supply.teesp01Part.eesp01PartPrefixCodeC"/>&minus;<bean:write name="requestItem" property="teesp04Supply.teesp01Part.eesp01PartBaseCodeC"/>&minus;<bean:write name="requestItem" property="teesp04Supply.teesp01Part.eesp01PartSuffixCodeC"/>
						</logic:equal>
					</display-el:column>
					<display-el:column title="${percentIncreaseTitle}" style="width: 9%;" class="cell1 text_bold border1_right border1_top align_center" headerClass="header border_right">
						<logic:empty name="requestItem" property="eesr02ReqitmIncrPercentC">-</logic:empty>
						<logic:notEmpty name="requestItem" property="eesr02ReqitmIncrPercentC">
							<bean:write name="requestItem" property="eesr02ReqitmIncrPercentC"/>
						</logic:notEmpty>
					</display-el:column>
					<display-el:column title="${priceTitle}" style="width: 9%;" class="cell1 text_bold border1_right border1_top align_center" headerClass="header border_right">
						<logic:empty name="requestItem" property="eesr02ReqitmNewpriceAmounA">-</logic:empty>
						<logic:notEmpty name="requestItem" property="eesr02ReqitmNewpriceAmounA">
							<bean:write name="requestItem" property="eesr02ReqitmNewpriceAmounA"/>
						</logic:notEmpty>
					</display-el:column>
					<display-el:column title="${statusTitle}" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
						<logic:equal name="requestItem" property="eesr02ReqitmStatusCodeC" value="P">
							<bean:message key="request.label.pending"/>
						</logic:equal>
						<logic:equal name="requestItem" property="eesr02ReqitmStatusCodeC" value="R">
							<bean:message key="request.label.rejected"/>
						</logic:equal>
						<logic:equal name="requestItem" property="eesr02ReqitmStatusCodeC" value="I">
							<bean:message key="request.label.inProcess"/>
						</logic:equal>
						<logic:equal name="requestItem" property="eesr02ReqitmStatusCodeC" value="C">
							<bean:message key="request.label.closed"/>
						</logic:equal>
					</display-el:column>
					<display-el:column title="${effDateTitle}" property="eesr02ReqitmEffectiveDateY" decorator="ar.com.ford.it.fullEconomics.view.displaytag.DateDecorator"  style="width: 10%;"  class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right" />
					<display-el:column title="${EconLevelTitle}" property="eesr02ReqitmEcolevelDateY" decorator="ar.com.ford.it.fullEconomics.view.displaytag.DateDecorator"  style="width: 14%;"  class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right" />
					<display-el:column title="${vehicleLineTitle}" style="width: 10%;" class="cell1 text_bold border1_right border1_top align_center" headerClass="header border_right">
						<logic:empty name="requestItem" property="ncas012VehicleVw">*</logic:empty>
						<logic:notEmpty name="requestItem" property="ncas012VehicleVw">
							<bean:write name="requestItem" property="ncas012VehicleVw.cas012VehicleCodeC"/>
						</logic:notEmpty>
					</display-el:column>
					<display-el:column title="${creationTitle}" decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator" class="cell1 text_bold border1_right border1_top align_center" headerClass="header border_right" >
						<bean:write name="requestItem" property="eesr02CreateUserC"/><br />
						<bean:write name="requestItem" property="eesr02CreateS"/>
					</display-el:column>
					<display-el:column title="${closureTitle}" decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator" class="cell1 text_bold border1_right border1_top align_center" headerClass="header border_right" >
						<logic:empty name="requestItem" property="teesr01Request.eesr01RequestClosureUserC">
							&minus;
						</logic:empty>
						<logic:notEmpty name="requestItem" property="teesr01Request.eesr01RequestClosureUserC">
							<bean:write name="requestItem" property="teesr01Request.eesr01RequestClosureUserC"/><br />
							<bean:write name="requestItem" property="teesr01Request.eesr01RequestClosureS"/>
						</logic:notEmpty>
					</display-el:column>
					<display-el:column title="${actionsTitle}"  style="width: 10%;" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
						<html:button property="request" onclick="selectRequestItem(${requestItem.teesr01Request.eesr01RequestNumberK},${requestItem.eesr02ReqitmNumberK});" styleClass="button"><bean:message key="fullEconomics.popup.select" /></html:button>
					</display-el:column>
				</display-el:table>
			</td>		
		</tr>
	</table>
</html:form>